#pragma once

#include <cstdint>
#include <vector>

enum class OccupancyType : uint8_t { NONE = 0, BOUNDARY = 1, INSIDE = 2, OUTSIDE = 3 };

struct Point2d {
    Point2d() = default;
    Point2d(float temp_x, float temp_y) : x(temp_x), y(temp_y) {}
    float x = 0;
    float y = 0;
};

class Polygon {
public:
    Polygon(const std::vector<Point2d>& point2d_vec) : _corner_points(point2d_vec) { 
        init_internal_point(); 
    }

    const Point2d& internal_point() const { return _internal_point; }
    const std::vector<Point2d>& corner_points() const { return _corner_points; }

private:
    // Polygon内部任意一点, 可以用任意方法实现, 暂时使用了一个比较简单但不一定准确的方法
    void init_internal_point() {
        float x = 0;
        float y = 0;
        for (const auto& point : _corner_points) {
            x += point.x;
            y += point.y;
        }
        _internal_point = Point2d(x / _corner_points.size(), y / _corner_points.size());
    }

    Point2d _internal_point;
    std::vector<Point2d> _corner_points;
};
